GBML manual / Database

db_get

Reads one cell of a table: db_get(cars, "falcon", top_speed) is the top_speed of the row called falcon in the table cars. It is exactly the same as writing cars.falcon.top_speed; the call form is for a row whose name has a space or another mark in it (db_get(cars, "red car", top_speed)). The row is written in quotes and the column as its plain name. What you get back is the kind of value the column holds: a number, a whole number, text, yes or no, a color, or a sprite, sound, object or room.

Syntax

db_get(table, row, column) -> any

Arguments

NameType
tabletable
rowstring
columncolumn

Returns

any

Description

Reads one cell of a table. db_get(cars, "falcon", top_speed) is the top_speed of the row called falcon in the table cars.

It means exactly the same as the short way, cars.falcon.top_speed (Reading a cell the short way). Use the call when the row's name has a space or another mark in it, like db_get(cars, "red car", top_speed).

The row is written in quotes and the column as its plain name, with no quotes. You get back the kind of value the column holds: a number, a whole number, text, yes or no, a color, or a sprite, sound, object or room.

A table, row or column that is not there is a message that names the closest one.

Example

var s = db_get(cars, "falcon", top_speed);
var name = db_get(cars, "red car", label);

On the GBA

Settled when the game is built, so the row has to be written out: a row kept in a variable is refused. A cell in a fixed column becomes the plain value inside the game: reading it costs nothing and uses no memory. A cell in a Varying column is read from the game’s memory like any global variable. A typo in the table, row or column is a message that names the closest one.

See also: db_setTablesReading a cell the short wayVarying columns